const mysql = require('mysql2');
const MYSQL_CONFIG = require('../config/db');

const connection = mysql.createConnection(MYSQL_CONFIG);
connection.connect();

function exec(sql) {
    return new Promise((resolve, reject) => {
        connection.query(sql, (err, result) => {
            if (err) {
                console.log("======数据库执行SQL出错=====", err);
                reject(err);
                return;
            }
            resolve(result);
        })
    })
}

module.exports = {
    exec
}